package cn.iocoder.yudao.module.nmkj.controller.app.article;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.nmkj.controller.admin.article.vo.ArticlePageReqVO;
import cn.iocoder.yudao.module.nmkj.controller.admin.article.vo.ArticleRespVO;
import cn.iocoder.yudao.module.nmkj.dal.dataobject.article.ArticleDO;
import cn.iocoder.yudao.module.nmkj.service.article.ArticleService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "用户APP - 文章管理")
@RestController
@RequestMapping("/nmkj/article")
@Validated
public class AppArticleController {

    @Resource
    private ArticleService articleService;

    @GetMapping("/page")
    @Operation(summary = "获得文章管理分页")
    public CommonResult<PageResult<ArticleRespVO>> getArticlePage(@Valid ArticlePageReqVO pageReqVO) {
        pageReqVO.setStatus(1);
        PageResult<ArticleDO> pageResult = articleService.getArticlePage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, ArticleRespVO.class));
    }

}
